home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Gif View / GifView.jar / MapCanvas.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-08-15  |  3.2 KB  |  136 lines

  1. import java.io.InputStream;
  2. import javax.microedition.lcdui.Canvas;
  3. import javax.microedition.lcdui.Font;
  4. import javax.microedition.lcdui.Graphics;
  5. import javax.microedition.lcdui.Image;
  6.  
  7. class MapCanvas extends Canvas {
  8.    // $FF: renamed from: ├ú int
  9.    int field_0 = 0;
  10.    // $FF: renamed from: ├ñ int
  11.    int field_1;
  12.    // $FF: renamed from: ├Ñ int
  13.    int field_2;
  14.    // $FF: renamed from: ├ª int
  15.    int field_3;
  16.    // $FF: renamed from: ├º int
  17.    int field_4;
  18.    // $FF: renamed from: ├¿ javax.microedition.lcdui.Font
  19.    Font field_5 = null;
  20.    // $FF: renamed from: ├⌐ javax.microedition.lcdui.Image
  21.    Image field_6 = null;
  22.    // $FF: renamed from: ├¬ javax.microedition.lcdui.Graphics
  23.    Graphics field_7 = null;
  24.    // $FF: renamed from: ├½ boolean
  25.    boolean field_8 = false;
  26.    MatrixImage matrix;
  27.    // $FF: renamed from: ├¼ int
  28.    int field_9 = 100;
  29.    // $FF: renamed from: ├¡ java.lang.String
  30.    String field_10 = "GifView 1.0";
  31.    // $FF: renamed from: ├« java.lang.String
  32.    String field_11 = "JShape Software";
  33.    // $FF: renamed from: ├» java.lang.String
  34.    String field_12 = "2001 (C)";
  35.  
  36.    public void init() {
  37.       this.field_1 = ((Canvas)this).getWidth();
  38.       this.field_2 = ((Canvas)this).getHeight();
  39.       this.field_6 = Image.createImage(this.field_1, this.field_2);
  40.       this.field_7 = this.field_6.getGraphics();
  41.    }
  42.  
  43.    public MatrixImage CreateGifMatrixImage(String var1) {
  44.       try {
  45.          InputStream var2 = this.getClass().getResourceAsStream(var1);
  46.          GifDecoder var3 = new GifDecoder(var2);
  47.          MatrixImage var4 = var3.decodeMatrix();
  48.          var2.close();
  49.          var3.clear();
  50.          Object var6 = null;
  51.          return var4;
  52.       } catch (Exception var5) {
  53.          return null;
  54.       }
  55.    }
  56.  
  57.    public void paint(Graphics var1) {
  58.       if (this.field_5 == null) {
  59.          this.field_5 = var1.getFont();
  60.       }
  61.  
  62.       if (this.field_8) {
  63.          String var6 = " loading ";
  64.          int var9 = this.field_5.stringWidth(var6);
  65.          int var4 = (this.field_1 - var9) / 2;
  66.          int var5 = (this.field_2 - this.field_5.getHeight()) / 2;
  67.          var1.setColor(8421504);
  68.          var1.fillRect(var4, var5 - 2, var9, this.field_5.getHeight() + 4);
  69.          var1.setColor(0);
  70.          var1.drawRect(var4, var5 - 2, var9, this.field_5.getHeight() + 4);
  71.          var1.drawString(var6, this.field_1 / 2, var5 + this.field_5.getHeight(), 33);
  72.          var1.drawString(var6, this.field_1 / 2 + 1, var5 + this.field_5.getHeight(), 33);
  73.       } else if (this.field_0 == 0) {
  74.          var1.setColor(16777215);
  75.          var1.fillRect(0, 0, this.field_1, this.field_2);
  76.          var1.setColor(0);
  77.          int var2 = this.field_1 / 2;
  78.          int var3 = (this.field_2 - this.field_5.getHeight()) / 2;
  79.          var1.drawString(this.field_10, var2, var3, 33);
  80.          var3 += this.field_5.getHeight();
  81.          var1.drawString(this.field_11, var2, var3, 33);
  82.          var3 += this.field_5.getHeight();
  83.          var1.drawString(this.field_12, var2, var3, 33);
  84.       } else {
  85.          if (this.matrix == null) {
  86.             this.matrix = this.CreateGifMatrixImage("/boss.gif");
  87.             this.field_3 = (this.field_1 - this.matrix.width) / 2;
  88.             this.field_4 = (this.field_2 - this.matrix.height) / 2;
  89.          }
  90.  
  91.          this.field_7.setClip(0, 0, this.field_1, this.field_2);
  92.          this.field_7.setColor(16777215);
  93.          this.field_7.fillRect(0, 0, this.field_1, this.field_2);
  94.          if (this.matrix != null) {
  95.             this.matrix.setAlpha(this.field_9);
  96.             this.matrix.paint(this.field_7, this.field_3, this.field_4);
  97.          }
  98.  
  99.          this.field_7.setColor(16711680);
  100.          this.field_7.drawString("" + this.field_9 + "%", 1, 1, 20);
  101.          var1.drawImage(this.field_6, 0, 0, 20);
  102.       }
  103.    }
  104.  
  105.    public void keyProc(int var1) {
  106.       int var2 = this.field_9;
  107.       var1 = ((Canvas)this).getGameAction(var1);
  108.       if (var1 == 5 || var1 == 1) {
  109.          this.field_9 += 5;
  110.          if (this.field_9 > 100) {
  111.             this.field_9 = 100;
  112.          }
  113.       }
  114.  
  115.       if (var1 == 2 || var1 == 6) {
  116.          this.field_9 -= 5;
  117.          if (this.field_9 < 0) {
  118.             this.field_9 = 0;
  119.          }
  120.       }
  121.  
  122.       if (var2 != this.field_9) {
  123.          ((Canvas)this).repaint();
  124.       }
  125.  
  126.    }
  127.  
  128.    public void keyPressed(int var1) {
  129.       this.keyProc(var1);
  130.    }
  131.  
  132.    public void keyRepeated(int var1) {
  133.       this.keyProc(var1);
  134.    }
  135. }
  136.